const {jwtRouter} = require('../../util')
const router = jwtRouter()
const {query} = require('../../db')

let tableName = 'users'

router.get('/', async (req, res, next)=>{

    let sql = `SELECT * FROM ${tableName} WHERE id = ?`
    let ret = await query(sql, req.userId).catch(next)
    if(ret === undefined) return 

    res.json({
        'ok': 1,
        'data': ret[0]
    })
})

module.exports = router